package com.cpit.qualitycontrol.service.impl;

import com.cpit.platform.dao.UserRepository;
import com.cpit.platform.dto.User;
import com.cpit.qualitycontrol.common.constant.RoleConstant;
import com.cpit.qualitycontrol.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by xxx on 2017/10/12.
 */
@Service
public class CommonServiceImpl implements CommonService{

    @Autowired
    UserRepository userRepository;

    @Override
    public List<Integer> getPotevioEngineeringDeptUserIds() {
        //根据 ROLE_POTEVIO_ENGINEERING_DEPT 查询普天工程部人员
        List<User> userList = userRepository
                .findUsersByRoleId(RoleConstant.ROLE_POTEVIO_ENGINEERING_DEPT);
        //取得普天人员USER.id
        return userList.stream().map(e -> e.getId()).collect(Collectors.toList());
    }
}
